//
//  UIBarButtonItem+CQBarButtonItem.m
//  01-OC微博
//
//  Created by 陈乾 on 15/10/25.
//  Copyright © 2015年 陈乾. All rights reserved.
//

#import "UIBarButtonItem+CQBarButtonItem.h"

@implementation UIBarButtonItem (CQBarButtonItem)
+ (UIBarButtonItem *)barButtonItemWithImage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents
{
    UIButton *button = [[UIButton alloc] init];
    
    [button setBackgroundImage:image forState:UIControlStateNormal];
    //设置高亮
    [button setBackgroundImage:highImage forState:UIControlStateHighlighted];
    //监听方法
    [button addTarget:target action:action forControlEvents:controlEvents];
    
    //设置frame
    [button sizeToFit];
    
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}
@end
